Unbans a user using a mySQL database

You need a database with

ip = primary key
time = time banned
long = how long they are banned in hours (i.e 24)


==============================================================


function checkBan()
{
	$query = mysql_query("SELECT * FROM `ips` ORDER BY time DESC");
	while($r = mysql_fetch_array($query)
	{
		$unbanTime = $r['time'] + $r['long'] * 60 * 60;
		if(time() >= unbanTime)
		{
			if(mysql_query("DELETE FROM `ips` WHERE `ip` = '$ip'"))
			{
				return true; // User Unbanned
			}
			else
			{
				return false; //User Still Banned
		}
		else
		{
			return false;
		}
	}
}